import request from '@/config/axios'

// 项目主 VO
export interface ProjectVO {
  id: number // 项目ID
  employerId: number // 雇主ID
  title: string // 项目名称
  description: string // 项目描述
  experienceLevel: number // 经验等级
  district: string // 区域名称
  headCount: number // 雇佣人数
  paymentType: number // 付款方式
  totalBudget: number // 总预算
  status: number // 项目状态
}

// 项目主 API
export const ProjectApi = {
  // 查询项目主分页
  getProjectPage: async (params: any) => {
    return await request.get({ url: `/member/project/page`, params })
  },

  // 查询项目主详情
  getProject: async (id: number) => {
    return await request.get({ url: `/member/project/get?id=` + id })
  },

  // 新增项目主
  createProject: async (data: ProjectVO) => {
    return await request.post({ url: `/member/project/create`, data })
  },

  // 修改项目主
  updateProject: async (data: ProjectVO) => {
    return await request.put({ url: `/member/project/update`, data })
  },

  // 删除项目主
  deleteProject: async (id: number) => {
    return await request.delete({ url: `/member/project/delete?id=` + id })
  },

  // 导出项目主 Excel
  exportProject: async (params) => {
    return await request.download({ url: `/member/project/export-excel`, params })
  },

// ==================== 子表（项目里程碑） ====================

  // 获得项目里程碑列表
  getProjectMilestoneListByProjectId: async (projectId) => {
    return await request.get({ url: `/member/project/project-milestone/list-by-project-id?projectId=` + projectId })
  },
}
